﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="TransferClients.aspx.cs" Inherits="Admin_TransferClients" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<br />
<asp:HyperLink ID="AdminOperatorsLink" runat="server" NavigateUrl="Admin.aspx">Администраторская панель</asp:HyperLink>
    →
    <asp:HyperLink ID="AdminOperatorLink" runat="server" NavigateUrl="../Admin/Operators.aspx">Операторы</asp:HyperLink>
&nbsp;→
    <b><asp:Label ID="OperatorsLabel" runat="server" Text="Передача клиентов" ForeColor="black" Font-Bold="true"  style="font-size: medium;" ></asp:Label></b>
    <br />
    <br />
<asp:GridView ID="GridViewOperatorClients" runat="server" AutoGenerateColumns="False" 
    DataSourceID="SqlDataSourceOperatorClients" DataKeyNames="ProfileId">
    <Columns>
        <asp:TemplateField>
        <ItemTemplate>
            <asp:CheckBox ID="companyIsSelected" runat="server" />
        </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Предприятие" HeaderText="Предприятие" 
            SortExpression="Предприятие" />
        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
        <asp:BoundField DataField="Телефон" HeaderText="Телефон" 
            SortExpression="Телефон" />
    </Columns>
    <EmptyDataTemplate>
        У оператора нет клиентов.
    </EmptyDataTemplate>
</asp:GridView>
<br />
<br />
<asp:SqlDataSource ID="SqlDataSourceOperatorClients" runat="server" 
    ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
    
        
        SelectCommand="SELECT Company.CompanyName AS Предприятие, UserProfile.CompanyEmail AS Email, UserProfile.CompanyHeadPhone AS Телефон, UserProfile.ProfileId FROM Operator INNER JOIN UserProfile ON Operator.OperatorId = UserProfile.OperatotId INNER JOIN Company ON UserProfile.CompanyId = Company.CompanyId WHERE (Operator.OperatorId = @operatorId)">
    <SelectParameters>
        <asp:SessionParameter DefaultValue="-1" Name="operatorId" 
            SessionField="operatorId" />
    </SelectParameters>
</asp:SqlDataSource>

   <asp:GridView ID="GridViewOperators" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSourceOperators" DataKeyNames="OperatorId" 
        onselectedindexchanged="GridViewOperators_SelectedIndexChanged">
        <Columns>
            <asp:CommandField SelectText="Выбрать для передачи" ShowSelectButton="True" />
            <asp:BoundField DataField="Ф.И.О." HeaderText="Ф.И.О." 
                SortExpression="Ф.И.О." />
            <asp:BoundField DataField="Количество клиентов" 
                HeaderText="Количество клиентов" ReadOnly="True" 
                SortExpression="Количество клиентов" />
        </Columns>
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSourceOperators" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
        
        
        
        SelectCommand="SELECT Operator.Name AS [Ф.И.О.], COUNT(UserProfile.OperatotId) AS [Количество клиентов], Operator.OperatorId FROM Operator LEFT OUTER JOIN UserProfile ON Operator.OperatorId = UserProfile.OperatotId GROUP BY Operator.Name, Operator.OperatorId HAVING (Operator.OperatorId &lt;&gt; @operatorId)">
        <SelectParameters>
            <asp:SessionParameter Name="operatorId" SessionField="operatorId" />
        </SelectParameters>
    </asp:SqlDataSource>


</asp:Content>

